function checkdata() {
	if (!checkName(categoryadd.name.value)) return false;
	if (!checkDescr(categoryadd.descr.value)) return false;
	return true;
}

function checkName(sn){
	if( sn.length<3 || sn.length>40 ) {
		//alert("\请输入正确的名字,名字长度为3～40位！");
		document.getElementById("nameErr").innerHTML = "<font color = 'red'>Name's length is 3 to 40！</font>";
		categoryadd.name.focus();
		return false;
	}
	document.getElementById("nameErr").innerHTML = "";
	return true;
}

function checkDescr(cd){
	if(  cd.length>255 ) {
		//alert("\描述长度不能大于255個字符！");
		document.getElementById("descriptionErr").innerHTML = "<font color = 'red'>Length cannot exceed 255 characters！</font>";
		categoryadd.descr.focus();
		return false;
	}
	document.getElementById("descriptionErr").innerHTML = "";
	return true;
}

function strlen(str){
	var len;
	var i;
	len = 0;
	for (i=0;i<str.length;i++){
		if (str.charCodeAt(i)>255) len+=2; else len++;
	}
	return len;
}
function strlen2(str){
	var len;
	var i;
	len = 0;
	for (i=0;i<str.length;i++){
		if (str.charCodeAt(i)>255) return true;
	}
	return false;
}
function isWhiteWpace (s)
{
  var whitespace = " \t\n\r";
  var i;
  for (i = 0; i < s.length; i++){   
     var c = s.charAt(i);
     if (whitespace.indexOf(c) >= 0) {
		  return true;
	  }
   }
   return false;
}
function isSsnString (ssn)
{
	var re=/^[0-9a-z][\w-.]*[0-9a-z]$/i;
	if(re.test(ssn))
		return true;
	else
		return false;
}
/* function checkssn(gotoURL) {
   var ssn=categoryadd.username.value.toLowerCase();
   if (checkUserName(ssn)){
	   var open_url = gotoURL + "?username=" + ssn;
	   window.open(open_url,'','status=0,directories=0,resizable=0,toolbar=0,location=0,scrollbars=0,width=390,height=260');
	}
} */
